Calling NAG library routines from Visual Basic (or Excel) can provide a convenient way to quickly develop graphical user interfaces and packages that use mathematical routines.
The aim of this report is to show how the complete range of NAG C DLL routines can be called directly from Visual Basic, and thus allow programmers/package builders maximum flexibility when incorporating calls to NAG library routines into their Visual Basic code.
1 IntroductionThe PC Windows environment is constructed so that all applications make calls to Dynamic Link Libraries (DLLs). These DLLs may contain system library routines provided by a particular computer vendor (e.g., the DLLs for Windows 95, Windows 98 and Windows NT supplied by Microsoft) or may be customized third party DLLs which provide a set of specialized functions (e.g., graphical, mathematical, text processing, etc).
NAG has developed 32-bit mathematical DLLs containing the routines in its Fortran 77 and C numerical libraries [1], [2]. It is envisaged that these routines will be mainly used by mathematical/scientific programmers who use Visual C++, Fortran PowerStation or Visual Basic to build their applications.
In particular, calling NAG library routines from Visual Basic (or Excel [3]) can provide a convenient way to quickly develop graphical user interfaces and packages that use mathematical routines. These interfaces, which may use dialog boxes, menus, etc., are simple to use and do not require the end-user to have any knowledge of the underlying DLL routine, or even computer languages such as Fortran 77, C and Visual Basic [4], [5].
This report is intended for Visual Basic programmers/package builders, and is concerned with calling the NAG C DLL routines from Visual Basic.
The main issues associated with using the DLL routines are
Here we use an alternative approach and illustrate how the full range of C Library routines can be called directly from Visual Basic, and thus give programmers maximum flexibility when using the NAG C DLL.
A rudimentary understanding of pointers is required and, in certain circumstances, an auxiliary DLL needs to be built (template C code is provided for this).
Appendix C contains Visual Basic example code fragments.
This section considers the Visual Basic data types required to match those that occur in the routine argument lists of a (32-bit) NAG C DLL. (More detail concerning data types can be found in the NAG C Library manuals [1]).
A brief summary of the fundamental types is
| C types | Size in bytes | Visual Basic types |
| Char | 1 | String 1 |
| Integer | 4 | Long |
| Boolean | 4 | Long |
| Int | 4 | Long |
| Double | 8 | Double |
typedef struct {double re, im;} Complex;
Boolean and enumeration types
In Visual Basic all Boolean or enumeration variables should be declared as type Long. For example the following C code
#define Nag_RK_method_start 53
#define Nag_IncludeMean_start 281
typedef enum {Nag_MeanInclude=Nag_IncludeMean_start, Nag_MeanZero}
Nag_IncludeMean;
typedef enum {Nag_RK_2_3=Nag_RK_method_start, Nag_RK_4_5, Nag_RK_7_8}
Nag_RK_method;
Nag_IncludeMean mean;
Nag_RK_method rk;
Boolean printit, stopit;
mean = Nag_MeanZero;
mean = Nag_MeanInclude;
printit = TRUE;
stopit = FALSE;
rk = Nag_RK_7_8;
rk = Nag_RK_2_3
can be written in Visual Basic as
Dim mean As Long Dim rk As Long Dim printit As Long Dim stopit As Long mean = 282 mean = 281 printit = 1 stopit = 0 rk = 55 rk = 53where FALSE = 0 and TRUE = 1.
By default, enumerators in a given C enumeration type declaration start at zero and increase by 1 as the declaration is read from left to right. However, if a given enumerator is assigned a value then subsequent enumerators continue the progression from the assigned value (Appendix B provides a list of the enumeration types used by the NAG C DLL).
Many of the DLL routines use structures in their argument lists. Sometimes, for example in the Chapters d02 and e04, these structures are rather complicated and may contain other structures. When the structure is relatively simple it is often convenient to define a Visual Basic user-defined type and then make a direct call to the DLL routine. Complicated structures are most easily dealt with by the use of an auxiliary DLL (this is illustrated in the Optimize example in Appendix C).
A structure that is required by nearly all of the routines is the type NagError. This is defined as
typedef struct {
int code;
Boolean print;
char message[512];
void (*handler)(char*, int*, char*);
Integer errnum;
} NagError;
The corresponding Visual Basic user-defined type is
Type NagErrorType code As Long printm As Long Message(511) As String *1 handler As Long errnum As Long End Typewhere int, Integer and Boolean types have been replaced by Long and the pointer to the handler function has been replaced by a structure member of type Long.
As another example the type Nag_Spline (used by the routines e02bac and e02bbc) is defined as
typedef struct {
Integer n;
double *lamda;
double *c;
Integer init1;
Integer init2;
} Nag_Spline;
The corresponding Visual Basic user-defined type is
Type NagSpline n As Long lamda As Long c As Long init1 As Long init2 As Long End Typewhere both pointers to type double have been replaced by integers of type Long.
The C DLL routines are called by using the following syntax:
Declare Function "name" Lib "library name" Alias "decorated name" (arguments) _ As return typeOr
Declare Sub "name" Lib "library name" Alias "decorated name" (arguments)The routine arguments can be obtained from the appropriate NAG header file and the "decorated name" is generated from the DLL routine name using the following convention.
An underscore (_) is prefixed to the routine name. The name is followed by the at-sign (@) character, followed by the number of bytes in the argument list. Appendix A lists the decorated names for the functions exported from the NAG C DLL.
For instance the ANSI C declarations for the routines s17agc and g01aac are
double s17agc(double x, NagError *fail); void g01aac(Integer n, double x[], double wt[], Integer *nvalid, double *xmean, double *xsd, double *xskew, double *xkurt, double *xmin, double *xmax, double *wsum, NagError *fail);and they would be declared in Visual Basic as
Declare Function s17agc Lib "nagcd.dll" Alias "_s17agc@12" (ByVal x As Double, _ ifail As NagErrorType) As Doubleand
Declare Sub g01aac Lib "nagcd.dll" Alias "_g01aac@48" (ByVal n As Long, _ x As Double, wt As double, nvalid As Long, xmean As Double, _ xsd As Double, xskew As Double, xkurt As Double, xmin As Double, _ xmax As Double, wsum As Double, ifail As NagErrorType)In C, pointers are used to pass arguments by reference (e.g., double *xsd, Integer *nvalid, double x[], etc.); here the notation [] is used to denote an array argument.
When arguments are passed by value in C the syntax type variable name (e.g., Integer n, double x, etc.) is used.
In Visual Basic, by default, all arguments are passed by reference; the keyword ByVal is required to pass an argument by value.
Many of the NAG C Library routines make use of null pointers to indicate that an argument is to be ignored and default action is to be taken.
For example the C routine g01aac has a pointer argument wt which allows the routine to perform statistical computations involving weighted data. If this argument is set to the null pointer then unweighted calculations are performed; all the weights are assumed to be 1. In Visual Basic this can be accomplished by declaring g01aac as follows:
Declare Sub g01aac Lib "nagcd.dll" Alias "_g01aac@48" (ByVal n As Long, _ x As Double, ByVal wt As Long, nvalid As Long, xmean As Double, _ xsd As Double, xskew As Double, xkurt As Double, xmin As Double, _ xmax As Double, wsum As Double, ifail As NagErrorType)where the declaration wt As Long (instead of wt As double) has been used to allow this argument to be used as a pointer. The routine calls
Call g01aac(n, x(0), ByVal 0&, nvalid, xmean, xsd, xskew, xkurt, xmin, xmax, _ wsum, pfail) Call g01aac(n, x(0), 0, nvalid, xmean, xsd, xskew, xkurt, xmin, xmax, wsum, _ pfail)are both valid and result in unweighted calculations being performed.
The use of null pointers to indicate default behaviour can also be accomplished when the routines have function arguments. For example the routine d02ejc has the function arguments fcn, pederv, g and output, and an ANSI C function declaration
d02ejc (Integer neq, NAG_D02EJC_FUN fcn, NAG_D02EJC_PFUN pederv, double *t, double y[], double tend, double tol, Nag_ErrorControl err_c, NAG_D02EJC_OUTFUN output, NAG_D02EJC_GFUN g, Nag_User *comm, NagError *fail);If it is declared in Visual Basic as
Declare Sub d02ejc Lib "nagcd.dll" Alias "_d02ejc@56" (ByVal neq As Long, _ ByVal ptr_fcn As Long, ByVal ptr_pederv As Long, x As Double, _ y As Double, ByVal xend As Double, ByVal tol As Double, _ ByVal err_c As Long, ByVal ptr_output As Long, ByVal ptr_g As Long, _ comm As Nag_User, ifail As NagErrorType)then the calls
ptr = d02ejc_fcn Call d02ejc(neq, ptr, ByVal 0&, x, y(0), xend, tol, err_c, ByVal 0&, _ ByVal 0&, comm, pfail) Call d02ejc(neq, ptr, 0, x, y(0), xend, tol, err_c, 0, 0, comm, pfail)both result in the internal evaluation of the Jacobian pederv. The next section gives more detail concerning function arguments; the ODE example section illustrates the use of the routine d02ejc.
In contrast to C, Visual Basic procedures are not allowed to have function arguments. This limitation creates a problem when using and declaring DLL routines that require function arguments (these routines are mainly in the d and e chapters of NAG library). A solution to this problem is to create an auxiliary DLL which both defines the required function arguments and also exports pointers to them. These function pointers can then be used in the routine argument lists of DLL procedures called from Visual Basic. The Visual Basic code fragments and auxiliary DLL template C code for the ODE, Optimize and Integrate examples given in Appendix C illustrate this.
6 Two-dimensional array arguments
In Visual Basic multi-dimensional arrays are stored by columns (as in Fortran) rather than by rows, which is the C convention. This means that care must be taken when a DLL routine has matrix (two-dimensional array) arguments.
For example, assume that a 3 by 2 matrix
11 12 21 22 31 32is stored in a Visual Basic 2-dimensional array a in the natural manner, as in the following code fragment.
Dim a(2, 1) As Double a(0, 0) = 11 a(1, 0) = 12 a(2, 0) = 31 a(0, 1) = 12 a(1, 1) = 22 a(2, 1) = 32The array a consists of 6 elements stored in column order, as follows:
11 21 31 12 22 32.However, routines in the NAG C DLL follow the standard C convention that two-dimensional arrays are stored in row order. Suppose the array a were passed to a NAG C routine (f02wec, say, as in the SVD example in Appendix C)
Call f02wec(3, 2, a(0, 0), . . . . )where the first two arguments specify the number of rows and columns in the matrix. The routine would treat the array as representing a 3 by 2 matrix stored in row order
11 21 31 12 22 32which is not the intended matrix A.
One solution (which is used in Appendix C) is to store the matrix in a one-dimensional array a1, with the element a1(i, j) stored in a1(i - 1) * tda + j - 1), where tda is the trailing dimension of the matrix (in this case 2).
Dim a1(5) As Double Dim tda As Long tda = 2 a1(0) = 11 a1(1) = 12 a1(2) = 21 a1(3) = 22 a1(4) = 31 a1(5) = 32 Call f02wec(3, 2, a1(0), tda . . . . )Another solution is to store the transpose of the matrix A in a two-dimensional array at, with tda now being the leading dimension of the array at
Dim at(1, 2) As Double Dim tda As Long tda = 2 at(0, 0) = 11 at(0, 1) = 21 at(0, 2) = 31 at(1, 0) = 12 at(1, 1) = 22 at(1, 2) = 32 Call f02wec(3, 2, at(0, 0), tda, . . . . )The Visual Basic array at can be larger than is needed to store the 2 by 3 matrix AT; in order that the C routine accesses the correct array elements it is essential that tda is set to the correct value
Dim at(3, 5) As Double Dim tda As Long . . Call f02wec(3, 2, at(0, 0), tda, . . . . )7 Allocation of storage
The DLL utility routines x04bec and x04bfc have been provided to facilitate pointer manipulation from within Visual Basic. These routines are included in the DLL vb_utility.dll which is included as part of the Visual Basic demonstration materials. Their Visual Basic declarations are
Declare Sub set_pointer Lib "nagcd.dll" Alias _ "_x04bec@12" (ptr As Long, ar As Double, n As Long) Declare Sub get_pointer Lib "nagcd.dll" Alias _ "_x04bfc@12" (ptr As Long, ar As Double, n As Long)}The routine set_pointer allocates 8n bytes of internal storage to the pointer ptr and copies n elements (of type double) from the Visual Basic array ar.
The routine get_pointer copies n elements from the internal memory associated with pointer ptr to the Visual Basic array ar (of type double).
A further utility routine x04bdc is used to free the memory allocated by x04bec; it can be declared as
Declare Sub free Lib "nagcd.dll" Alias "_x04bdc@4" (ptr As Long)The use of set_pointer can be illustrated by slightly modifying the example given in the section on null pointers. In the following code extract the first call to g01aac uses the weights supplied in the array wt, while the second results in unweighted computations.
set_pointer(ptr, wt(0), n) Call g01aac(n, x(0), ptr, nvalid, xmean, xsd, xskew, xkurt, xmin, xmax, wsum, _ pfail) ptr = 0 Call g01aac(n, x(0), ptr, nvalid, xmean, xsd, xskew, xkurt, xmin, xmax, wsum, _ pfail)The Spline example, in Appendix C, illustrates the use of both get_pointer and set_pointer for variable assignment and retrieval within a structure of type Nag_Spline.
It is recommended that the unoptimized NAG C DLL, "nagcd", be used within Excel/Visual Basic; tests have shown that errors occur when some functions within the optimized DLL, "nagc", are called from Visual Basic.
Functions in Chapter a02 that pass the structure Complex by value cannot be called from Visual Basic. This is because user-defined types may not be passed from Visual Basic to a C DLL by value.
In Excel, function names of the form c0[1-9][a-z][a-z][a-z] (e.g., c02afc) are not permitted; this means that care must be exercised when using the Visual Basic alias facility on routines in Chapters c02, c05 and c06.
This section provides brief comments on the example code fragments of Appendix C. All the examples use the unoptimized NAG C DLL, "nagcd", and some make use of an auxiliary DLL called "examples_interfaces". The example code has been written so that it can be used from either Excel or Visual Basic.
This example illustrates the use of the (previously defined) type Nag_Spline that is passed to the DLL routines e02bac and e02bbc. This structure contains two pointers of type double, c and lamda. The memory associated with pointer lamda must be allocated before e02bac is called while the memory associated with c is allocated internally by the routine.
In this example the DLL routine is given two Visual Basic declarations. The function f02wec is used to calculate both the singular values and also the left and right singular vectors of a matrix A; it also requires the declaration of "dummy" arrays for certain array arguments that are not referenced. The function f02wec_ptr is used to calculate the singular values only, and contains the declarations ByVal q As Long, ByVal b As Long and ByVal pt As Long within its argument list. This enables assignment of null pointers to these arguments and thus avoids the use of "dummy" array arguments when the routine is called. The example also illustrates how data is assigned to the input array a; note tda is the second (trailing) dimension of the matrix A.
In the example d02ejc first computes a solution with a user-defined Jacobian and then solves the same problem using internal evaluation of the Jacobian. Use is made of pointer arguments to access functions, which have return type, void.
This example shows how the optimizer routine e04ucc can be called directly from the Visual Basic.
The example illustrates how several integrals can be evaluated through the use of different function pointers, which are exported from an auxiliary DLL. In this case the pointers are used to access functions which have return type double.
[1] The NAG C Library, Mark 5 (1998). NAG Ltd, Wilkinson House, Jordan Hill Road, Oxford, UK.
[2] The NAG Fortran Library, Mark 18 (1997). NAG Ltd, Wilkinson House, Jordan Hill Road, Oxford, UK.
[3] Microsoft Office 97 (1997). Microsoft.
[4] Kernighan B W and Ritchie D M (1988): The C Programming Language. Prentice Hall Software Series.
[5] Visual Basic 5 (1988). Microsoft. (1988)
Appendix A. Decorated function names
The following is a list of the decorated function names exported by the NAG C DLLs.
_a00aac@0 _a00abc@4 _a02bac@16 _a02bbc@16 _a02bcc@16 _a02cac@32 _a02cbc@32 _a02ccc@32 _a02cdc@32 _a02cec@16 _a02cfc@16 _a02cgc@32 _a02chc@32 _a02dac@16 _a02dbc@16 _a02dcc@16 _a02ddc@20 _a02dec@24 _a02dfc@32 _a02dgc@16 _a02dhc@16 _a02djc@16 _a02dkc@16 _a02dlc@16 _a02eic@32 _a02ejc@24 _c02afc@20 _c02agc@20 _c05adc@44 _c05nbc@28 _c05pbc@36 _c05sdc@48 _c05tbc@32 _c05ubc@40 _c05zbc@28 _c05zcc@32 _c06eac@12 _c06ebc@12 _c06ecc@16 _c06ekc@20 _c06fpc@20 _c06fpz@12 _c06fqc@20 _c06frc@24 _c06fuc@28 _c06gbc@12 _c06gcc@12 _c06gqc@16 _c06gsc@24 _c06gzc@12 _c06hac@20 _c06hbc@20 _c06hcc@24 _c06hdc@24 _d01ajc@56 _d01akc@56 _d01alc@64 _d01amc@52 _d01anc@68 _d01apc@76 _d01aqc@64 _d01asc@56 _d01bac@32 _d01bbc@40 _d01fcc@44 _d01gac@24 _d01gbc@56 _d01sjc@60 _d01skc@60 _d01slc@68 _d01smc@56 _d01snc@72 _d01spc@80 _d01sqc@68 _d01ssc@60 _d01tac@36 _d01wcc@48 _d01xbc@60 _d02cjc@52 _d02ejc@56 _d02gac@64 _d02gbc@72 _d02nmc@104 _d02nsc@24 _d02nvc@76 _d02pcc@44 _d02pdc@32 _d02ppc@4 _d02pvc@64 _d02pwc@16 _d02pxc@44 _d02pyc@24 _d02pzc@24 _d02qfc@40 _d02qwc@68 _d02qyc@4 _d02qzc@32 _d02rac@80 _d02xkc@72 _d02zac@20 _e01bac@20 _e01bec@20 _e01bfc@32 _e01bgc@36 _e01bhc@40 _e01dac@28 _e01sac@32 _e01sbc@24 _e01szc@4 _e02adc@36 _e02aec@24 _e02afc@16 _e02bac@28 _e02bbc@20 _e02bcc@24 _e02bdc@12 _e02bec@48 _e02dcc@56 _e02ddc@60 _e02dec@24 _e02dfc@28 _e04abc@48 _e04bbc@52 _e04ccc@28 _e04dgc@32 _e04fcc@44 _e04gbc@44 _e04hbc@36 _e04hcc@28 _e04hdc@36 _e04jbc@44 _e04kbc@44 _e04lbc@48 _e04mfc@48 _e04myc@24 _e04mzc@52 _e04ncc@68 _e04nfc@60 _e04nkc@72 _e04ucc@60 _e04unc@76 _e04xac@52 _e04xxc@4 _e04xyc@24 _e04xzc@12 _e04yac@36 _e04ycc@32 _f01bnc@20 _f01mcc@28 _f01qcc@24 _f01qdc@44 _f01qec@32 _f01rcc@24 _f01rdc@44 _f01rec@32 _f02aac@20 _f02abc@28 _f02adc@28 _f02aec@36 _f02afc@24 _f02agc@32 _f02awc@20 _f02axc@28 _f02bjc@56 _f02ecc@56 _f02gcc@56 _f02wec@72 _f02xec@72 _f03abc@24 _f03aec@28 _f03afc@28 _f03ahc@28 _f04adc@36 _f04agc@40 _f04ajc@32 _f04akc@32 _f04arc@24 _f04awc@40 _f04mcc@48 _f06eac@20 _f06efc@20 _f06pac@52 _f06pbc@60 _f06pcc@48 _f06pdc@52 _f06pec@44 _f06pfc@32 _f06pgc@36 _f06phc@28 _f06pjc@32 _f06pkc@36 _f06plc@28 _f06pmc@40 _f06ppc@32 _f06pqc@28 _f06prc@40 _f06psc@36 _f06sac@68 _f06sbc@76 _f06scc@64 _f06sdc@68 _f06sec@60 _f06sfc@32 _f06sgc@36 _f06shc@28 _f06sjc@32 _f06skc@36 _f06slc@28 _f06smc@48 _f06snc@48 _f06spc@32 _f06sqc@28 _f06src@48 _f06ssc@44 _f06yac@60 _f06ycc@56 _f06yfc@48 _f06yjc@48 _f06ypc@48 _f06yrc@56 _f06zac@76 _f06zcc@72 _f06zfc@56 _f06zjc@56 _f06zpc@48 _f06zrc@64 _f06ztc@72 _f06zuc@64 _f06zwc@72 _f11dac@72 _f11dcc@84 _f11dec@76 _f11gac@80 _f11gbc@28 _f11gcc@36 _f11jac@76 _f11jbc@44 _f11jcc@72 _f11jec@72 _f11xec@36 _f11zac@36 _f11zbc@36 _g01aac@48 _g01alc@16 _g01bjc@32 _g01bkc@28 _g01blc@32 _g01cec@12 _g01ddc@28 _g01dhc@24 _g01eac@16 _g01ebc@24 _g01ecc@24 _g01edc@32 _g01eec@48 _g01efc@32 _g01fac@16 _g01fbc@24 _g01fcc@20 _g01fdc@28 _g01fec@36 _g01ffc@36 _g01hac@28 _g02brc@36 _g02bxc@56 _g02cac@52 _g02cbc@72 _g02dac@100 _g02dcc@64 _g02ddc@60 _g02dec@44 _g02dfc@24 _g02dgc@64 _g02dkc@52 _g02dnc@52 _g02fac@36 _g02gac@120 _g02gbc@112 _g02gcc@116 _g02gdc@120 _g02gkc@48 _g02gnc@56 _g02hac@116 _g02hkc@60 _g03aac@68 _g03acc@88 _g03adc@72 _g03bac@60 _g03bcc@60 _g03cac@80 _g03ccc@52 _g03dac@72 _g03dbc@60 _g03dcc@88 _g03eac@44 _g03ecc@36 _g03efc@64 _g03ehc@40 _g03ejc@32 _g03fac@32 _g03fcc@40 _g03xzc@4 _g03zac@44 _g04bbc@76 _g04cac@68 _g04czc@24 _g05cac@0 _g05caz@20 _g05cbc@4 _g05ccc@0 _g05cfc@8 _g05cgc@12 _g05dac@16 _g05dbc@8 _g05ddc@16 _g05dyc@8 _g05eac@32 _g05ecc@16 _g05edc@20 _g05ehc@12 _g05ejc@20 _g05exc@24 _g05eyc@4 _g05ezc@8 _g05fec@28 _g05ffc@28 _g05hac@52 _g07cac@80 _g07dac@28 _g07dbc@92 _g07ddc@44 _g10cac@24 _g11aac@44 _g12aac@36 _g13abc@32 _g13acc@32 _g13bec@56 _g13bjc@76 _g13bxc@4 _g13byc@12 _g13bzc@4 _g13cac@68 _g13cbc@60 _g13ccc@72 _g13cdc@60 _g13cec@52 _g13cfc@48 _g13cgc@52 _g13eac@88 _g13ebc@88 _g13ecc@88 _g13edc@84 _g13ewc@40 _g13exc@40 _g13xzc@4 _h02bbc@64 _h02buc@48 _h02bvc@24 _h02xxc@4 _h02xyc@24 _h02xzc@12 _h03abc@56 _m01cac@16 _m01csc@28 _m01ctc@28 _m01cuc@20 _m01dsc@28 _m01esc@24 _m01fsc@36 _m01zac@12 _s10aac@8 _s10abc@12 _s10acc@12 _s11aac@12 _s11abc@8 _s11acc@12 _s13aac@12 _s13acc@12 _s13adc@8 _s14aac@12 _s14abc@12 _s14bac@36 _s15abc@8 _s15acc@8 _s15adc@8 _s15aec@8 _s17acc@12 _s17adc@12 _s17aec@12 _s17afc@12 _s17agc@12 _s17ahc@12 _s17ajc@12 _s17akc@12 _s18acc@12 _s18adc@12 _s18aec@12 _s18afc@12 _s18ccc@12 _s18cdc@12 _s18cec@8 _s18cfc@8 _s19aac@12 _s19abc@12 _s19acc@12 _s19adc@12 _s20acc@8 _s20adc@8 _s21bac@20 _s21bbc@28 _s21bcc@28 _s21bdc@36 _x02ahc@0 _x02ajc@0 _x02akc@0 _x02alc@0 _x02amc@0 _x04bay@8 _x04bbc@4 _x04bcc@8 _x04bdc@4 _x05aac@0Appendix B. Enumeration types
The following is a list of the enumeration types used in the NAG C DLLs (information concerning structure types can be found in the Nag_types.h header file).
#define MatrixTranspose_start 1 #define MatrixTriangle_start 4 #define MatrixUnitTriangular_start 6 #define OperationSide_start 8 #define PivotType_start 10 #define SequenceDirection_start 14 #define NormType_start 16 #define MatrixType_start 20 #define Nag_VectorOp_start 27 #define Nag_TransformDirection_start 29 #define Nag_QuadWeight_start 31 #define Nag_BoundInterval_start 35 #define Nag_TrigTransform_start 38 #define Nag_GaussFormulae_start 40 #define Nag_MCMethod_start 44 #define Nag_ErrorControl_start 46 #define Nag_MeshSet_start 49 #define Nag_RK_task_start 51 #define Nag_RK_method_start 53 #define Nag_ErrorAssess_start 56 #define Nag_SolDeriv_start 58 #define Nag_2d_Scat_Method_start 61 #define Nag_DerivType_start 63 #define Nag_Start_start 65 #define Nag_PrintType_start 72 #define Nag_GradChk_start 84 #define Nag_DPrintType_start 94 #define Nag_CheckType_start 100 #define Nag_DWantType_start 103 #define Nag_DerivInfo_start 107 #define Nag_DerivSet_start 113 #define Nag_FunType_start 118 #define Nag_LinFun_start 120 #define Nag_InitType_start 123 #define Nag_BoundType_start 128 #define Nag_ProblemType_start 134 #define Nag_EndState_start 153 #define Nag_DegenJob_start 186 #define Nag_SetStateMode_start 189 #define Nag_SparseQP_LU_Type_start 191 #define Nag_SparseQP_LU_SolveType_start 194 #define Nag_SparseQP_BasisFactType_start 197 #define Nag_CrashType_start 199 #define Nag_ScaleType_start 203 #define Nag_WhereElements_start 207 #define Nag_InitRotation_start 209 #define Nag_Select_Eigenvalues_start 211 #define Nag_SolveSystem_start 213 #define Nag_SparseNsym_Method_start 219 #define Nag_SparseNsym_Fact_start 222 #define Nag_SparseNsym_Piv_start 224 #define Nag_SparseNsym_Zeros_start 228 #define Nag_SparseNsym_Dups_start 231 #define Nag_SparseSym_Method_start 234 #define Nag_SparseSym_Fact_start 236 #define Nag_SparseNsym_PrecType_start 238 #define Nag_SparseSym_Weight_start 241 #define Nag_SparseSym_Bisection_start 243 #define Nag_SparseSym_Norm_start 245 #define Nag_SparseSym_Term_start 248 #define Nag_SparseSym_CheckData_start 250 #define Nag_SparseSym_Piv_start 252 #define Nag_SparseSym_PrecType_start 255 #define Nag_SparseSym_Dups_start 259 #define Nag_SparseSym_Zeros_start 261 #define Nag_TailProbability_start 263 #define Nag_Scores_start 268 #define Nag_Ties_start 274 #define Nag_IncludeWeight_start 279 #define Nag_IncludeMean_start 281 #define Nag_UpdateObserv_start 283 #define Nag_SumSquare_start 285 #define Nag_Initialize_start 287 #define Nag_Link_start 289 #define Nag_RegType_start 297 #define Nag_PsiFun_start 301 #define Nag_SigmaEst_start 307 #define Nag_CovMatrixEst_start 311 #define Nag_SigmaSimulEst_start 314 #define Nag_PrinCompMat_start 316 #define Nag_PrinCompScores_start 320 #define Nag_Weightstype_start 324 #define Nag_RotationLoading_start 327 #define Nag_TransNorm_start 329 #define Nag_RotationScale_start 335 #define Nag_FacMat_start 337 #define Nag_FacScoreMethod_start 340 #define Nag_FacRotation_start 342 #define Nag_GroupCovars_start 344 #define Nag_MahalDist_start 346 #define Nag_DiscrimMethod_start 348 #define Nag_PriorProbability_start 350 #define Nag_MatUpdate_start 353 #define Nag_DistanceType_start 355 #define Nag_VarScaleType_start 358 #define Nag_ClusterMethod_start 362 #define Nag_DendOrient_start 368 #define Nag_Eigenvalues_start 372 #define Nag_ScaleCriterion_start 374 #define Nag_Blocks_start 376 #define Nag_DiscreteDistrib_start 379 #define Nag_PopVar_start 381 #define Nag_Smooth_Type_start 383 #define Nag_FreqTime_start 385 #define Nag_Likelihood_start 387 #define Nag_LagWindow_start 391 #define Nag_MeanOrTrend_start 395 #define Nag_LoggedSpectra_start 398 #define Nag_state_start 400 #define Nag_ab_input_start 402 #define Nag_ObserverForm_start 404 #define Nag_ControllerForm_start 406 #define Nag_OutputType_start 408 #define Nag_BB_Fail_start 412 #define Nag_MIP_ProbType_start 415 #define Nag_Node_Selection_start 421 #define Nag_Var_Selection_start 427 #define Nag_Branch_Direction_start 431 #define Nag_NodeStatus_start 435 #define Nag_SortOrder_start 442 #define Nag_SearchMatch_start 444 #define Nag_HashError_start 446C Chapters
typedef enum {Nag_Convolution=Nag_VectorOp_start, Nag_Correlation} Nag_VectorOp;
typedef enum {Nag_ForwardTransform=Nag_TransformDirection_start,
Nag_BackwardTransform}Nag_TransformDirection;
D Chapters
typedef enum {Nag_Alg=Nag_QuadWeight_start, Nag_Alg_loga, Nag_Alg_logb,
Nag_Alg_loga_logb} Nag_QuadWeight;
typedef enum {Nag_UpperSemiInfinite=Nag_BoundInterval_start,
Nag_LowerSemiInfinite, Nag_Infinite} Nag_BoundInterval;
typedef enum {Nag_Cosine=Nag_TrigTransform_start, Nag_Sine} Nag_TrigTransform;
typedef enum {Nag_Legendre=Nag_GaussFormulae_start, Nag_Rational, Nag_Laguerre,
Nag_Hermite} Nag_GaussFormulae;
typedef enum {Nag_OneIteration=Nag_MCMethod_start, Nag_ManyIterations}
Nag_MCMethod;
typedef enum {Nag_Relative=Nag_ErrorControl_start, Nag_Absolute, Nag_Mixed}
Nag_ErrorControl;
typedef enum {Nag_UserInitMesh=Nag_MeshSet_start,Nag_DefInitMesh} Nag_MeshSet;
typedef enum {Nag_RK_range=Nag_RK_task_start, Nag_RK_onestep} Nag_RK_task;
typedef enum {Nag_RK_2_3=Nag_RK_method_start, Nag_RK_4_5, Nag_RK_7_8}
Nag_RK_method;
typedef enum {Nag_ErrorAssess_off=Nag_ErrorAssess_start, Nag_ErrorAssess_on}
Nag_ErrorAssess;
typedef enum {Nag_Sol=Nag_SolDeriv_start, Nag_Der, Nag_SolDer} Nag_SolDeriv;
E Chapters
typedef enum {Nag_StartNotSet=Nag_Start_start, Nag_Cold, Nag_Warm, Nag_Hot,
Nag_NewStart, Nag_ReStart, Nag_Continue} Nag_Start;
typedef enum {Nag_RC=Nag_2d_Scat_Method_start, Nag_Shep} Nag_2d_Scat_Method;
typedef enum {Nag_LeftDerivs=Nag_DerivType_start, Nag_RightDerivs}
Nag_DerivType;
typedef enum {Nag_PrintNotSet=Nag_PrintType_start, Nag_NoPrint, Nag_Soln_Root,
Nag_Soln, Nag_Iter, Nag_Iter_Long, Nag_Soln_Root_Iter,
Nag_Soln_Iter, Nag_Soln_Iter_Long, Nag_Soln_Iter_Const,
Nag_Soln_Iter_Diag, Nag_Soln_Iter_Full} Nag_PrintType;
typedef enum {Nag_ChkNotSet=Nag_GradChk_start, Nag_NoCheck, Nag_SimpleCheck,
Nag_CheckObj,Nag_CheckCon, Nag_CheckObjCon, Nag_XsimpleCheck,
Nag_XCheckObj, Nag_XCheckCon, Nag_XCheckObjCon} Nag_GradChk;
typedef enum {Nag_D_NotSet=Nag_DPrintType_start, Nag_D_NoPrint, Nag_D_Print,
Nag_D_Sum, Nag_D_Full, Nag_D_Dbg} Nag_DPrintType;
typedef enum {Nag_ObjCheck=Nag_CheckType_start, Nag_ConCheck, Nag_DiffInt}
Nag_CheckType;
typedef enum {Nag_DWant_NotSet=Nag_DWantType_start, Nag_Grad_HessDiag,
Nag_HessFull, Nag_Grad_HessFull} Nag_DWantType;
typedef enum {Nag_DInfo_NotSet=Nag_DerivInfo_start, Nag_Deriv_OK,
Nag_Fun_Constant, Nag_Fun_LinearOdd, Nag_2ndDeriv_Large,
Nag_1stDeriv_Small} Nag_DerivInfo;
typedef enum {Nag_DerivNotSet=Nag_DerivSet_start, Nag_SomeG_SomeJ,
Nag_AllG_SomeJ, Nag_SomeG_AllJ, Nag_AllG_AllJ} Nag_DerivSet;
typedef enum {Nag_Deriv=Nag_FunType_start, Nag_NoDeriv} Nag_FunType;
typedef enum {Nag_LinFunNotSet=Nag_LinFun_start, Nag_Lin_Deriv, Nag_Lin_NoDeriv}
Nag_LinFun;
typedef enum {Nag_InitNotSet=Nag_InitType_start, Nag_Init_None, Nag_Init_F_G_H,
Nag_Init_All, Nag_Init_H_S} Nag_InitType;
typedef enum {Nag_BoundNotSet=Nag_BoundType_start, Nag_Bounds, Nag_BoundsZero,
Nag_BoundsEqual, Nag_NoBounds, Nag_NoBounds_One_Call}
Nag_BoundType;
typedef enum {Nag_ProbTypeNotSet=Nag_ProblemType_start, Nag_FP, Nag_LP, Nag_QP1,
Nag_QP2, Nag_QP3, Nag_QP4, Nag_LS1, Nag_LS2, Nag_LS3, Nag_LS4,
Nag_SparseFP, Nag_SparseLP, Nag_SparseQP, Nag_SparseFPE,
Nag_SparseFPL, Nag_SparseFPS, Nag_SparseQPP, Nag_SparseQPS}
Nag_ProblemType;
typedef enum {Nag_EndStateNotSet=Nag_EndState_start, Nag_Feasible,
Nag_Deadpoint, Nag_Weakmin, Nag_Unbounded, Nag_Infeasible,
Nag_Too_Many_Iter, Nag_OptimalNag_Hess_Too_Big, Nag_Cycling,
Nag_Not_Converged, Nag_Not_Kuhn_Tucker, Nag_Deriv_Error,
Nag_Hess_Indefinite, Nag_Basis_Ill_Cond, Nag_Basis_Singular,
Nag_Out_Of_Workspace, Nag_MIP_Best_ISol, Nag_MIP_Stop_First_Isol
Nag_MIP_No_ISol, Nag_MIP_Root_Unbounded, Nag_MIP_Root_Infeasible
Nag_MIP_Root_Max_Itn, Nag_MIP_Root_Big_Hess, Nag_MIP_Max_Itn_ISol,
Nag_MIP_Max_Nodes_ISol, Nag_MIP_Big_Hess_ISol,
Nag_MIP_Max_Depth_ISol, Nag_MIP_Big_Hess_No_Isol,
Nag_MIP_Max_Itn_No_ISol, Nag_MIP_Max_Nodes_No_ISol,
Nag_MIP_Max_Depth_No_ISol, Nag_MIP_User_Stop} Nag_EndState;
typedef enum {Nag_DegenInit=Nag_DegenJob_start, Nag_DegenOptimal,
Nag_DegenEndCycle} Nag_DegenJob;
typedef enum {Nag_StatesInternal=Nag_SetStateMode_start, Nag_StatesExternal}
Nag_SetStateMode;
typedef enum {Nag_LU_TypeB=Nag_SparseQP_LU_Type_start, Nag_LU_TypeBS,
Nag_LU_TypeBT} Nag_SparseQP_LU_Type;
typedef enum {Nag_LU_SolveL=Nag_SparseQP_LU_SolveType_start, Nag_LU_SolveB,
Nag_LU_SolveBt} Nag_SparseQP_LU_SolveType;
typedef enum {Nag_BasisFactB=Nag_SparseQP_BasisFactType_start, Nag_BasisFactBS}
Nag_SparseQP_BasisFactType;
typedef enum {Nag_CrashNotSet=Nag_CrashType_start, Nag_NoCrash, Nag_CrashOnce,
Nag_CrashTwice} Nag_CrashType;
typedef enum {Nag_ScaleNotSet=Nag_ScaleType_start, Nag_NoScale, Nag_RowColScale,
Nag_ExtraScale} Nag_ScaleType;
F Chapters
typedef enum {NoTranspose=MatrixTranspose_start, Transpose, ConjugateTranspose}
MatrixTranspose;
typedef enum {UpperTriangle=MatrixTriangle_start, LowerTriangle} MatrixTriangle;
typedef enum {UnitTriangular=MatrixUnitTriangular_start, NotUnitTriangular}
MatrixUnitTriangular;
typedef enum {LeftSide=OperationSide_start, RightSide} OperationSide;
typedef enum {BottomPivot=PivotType_start, TopPivot, VariablePivot, FixedPivot}
PivotType;
typedef enum {ForwardSequence=SequenceDirection_start, BackwardSequence}
SequenceDirection;
typedef enum {OneNorm=NormType_start, FrobeniusNorm, MaxAbsValue, InfinityNorm}
NormType;
typedef enum {General=MatrixType_start, UpperTriangular, LowerTriangular,
SymmetricUpper, SymmetricLower, HermitianUpper, HermitianLower}
MatrixType;
typedef enum {Nag_ElementsIn=Nag_WhereElements_start, Nag_ElementsSeparate}
Nag_WhereElements;
typedef enum {Nag_Supplied=Nag_InitRotation_start, Nag_NotSupplied}
Nag_InitRotation;
typedef enum {Nag_Select_Modulus=Nag_Select_Eigenvalues_start,
Nag_Select_RealPart} Nag_Select_Eigenvalues;
typedef enum {Nag_LDLTX=Nag_SolveSystem_start, Nag_LDX, Nag_DLTX, Nag_LLTX,
Nag_LX, Nag_LTX} Nag_SolveSystem;
typedef enum {Nag_SparseNsym_RGMRES=Nag_SparseNsym_Method_start,
Nag_SparseNsym_CGS, Nag_SparseNsym_BiCGSTAB} Nag_SparseNsym_Method;
typedef enum {Nag_SparseNsym_ModFact=Nag_SparseNsym_Fact_start,
Nag_SparseNsym_UnModFact} Nag_SparseNsym_Fact;
typedef enum {Nag_SparseNsym_NoPiv=Nag_SparseNsym_Piv_start,
Nag_SparseNsym_UserPiv, Nag_SparseNsym_PartialPiv,
Nag_SparseNsym_CompletePiv} Nag_SparseNsym_Piv;
typedef enum {Nag_SparseNsym_RemoveZeros=Nag_SparseNsym_Zeros_start,
Nag_SparseNsym_KeepZeros, Nag_SparseNsym_FailZeros}
Nag_SparseNsym_Zeros;
typedef enum {Nag_SparseNsym_RemoveDups=Nag_SparseNsym_Dups_start,
Nag_SparseNsym_SumDups, Nag_SparseNsym_FailDups}
Nag_SparseNsym_Dups;
typedef enum {Nag_SparseSym_CG=Nag_SparseSym_Method_start,
Nag_SparseSym_Lanczos} Nag_SparseSym_Method;
typedef enum {Nag_SparseSym_ModFact=Nag_SparseSym_Fact_start,
Nag_SparseSym_UnModFact} Nag_SparseSym_Fact;
typedef enum {Nag_SparseNsym_NoPrec=Nag_SparseNsym_PrecType_start,
Nag_SparseNsym_SSORPrec, Nag_SparseNsym_JacPrec}
Nag_SparseNsym_PrecType;
typedef enum {Nag_SparseSym_Weighted=Nag_SparseSym_Weight_start,
Nag_SparseSym_UnWeighted} Nag_SparseSym_Weight;
typedef enum {Nag_SparseSym_Bisect=Nag_SparseSym_Bisection_start,
Nag_SparseSym_NoBisect} Nag_SparseSym_Bisection;
typedef enum {Nag_SparseSym_OneNorm=Nag_SparseSym_Norm_start,
Nag_SparseSym_TwoNorm, Nag_SparseSym_InfNorm} Nag_SparseSym_Norm;
typedef enum {Nag_SparseSym_TermLanczos=Nag_SparseSym_Term_start,
Nag_SparseSym_TermLanczosCG} Nag_SparseSym_Term;
typedef enum {Nag_SparseSym_NoCheck=Nag_SparseSym_CheckData_start,
Nag_SparseSym_Check} Nag_SparseSym_CheckData;
typedef enum {Nag_SparseSym_NoPiv=Nag_SparseSym_Piv_start,
Nag_SparseSym_MarkPiv, Nag_SparseSym_UserPiv} Nag_SparseSym_Piv;
typedef enum {Nag_SparseSym_Prec=Nag_SparseSym_PrecType_start,
Nag_SparseSym_NoPrec, Nag_SparseSym_SSORPrec,
Nag_SparseSym_JacPrec} Nag_SparseSym_PrecType;
typedef enum {Nag_SparseSym_SumDups=Nag_SparseSym_Dups_start,
Nag_SparseSym_RemoveDups} Nag_SparseSym_Dups;
typedef enum {Nag_SparseSym_KeepZeros=Nag_SparseSym_Zeros_start,
Nag_SparseSym_RemoveZeros} Nag_SparseSym_Zeros;
G Chapters
typedef enum {Nag_LowerTail=Nag_TailProbability_start, Nag_UpperTail,
Nag_TwoTailSignif, Nag_TwoTailConfid, Nag_TwoTail}
Nag_TailProbability;
typedef enum {Nag_RankScores=Nag_Scores_start, Nag_NormalScores, Nag_BlomScores,
Nag_TukeyScores, Nag_WaerdenScores, Nag_SavageScores} Nag_Scores;
typedef enum {Nag_AverageTies=Nag_Ties_start, Nag_LowestTies, Nag_HighestTies,
Nag_RandomTies, Nag_IgnoreTies} Nag_Ties;
typedef enum {Nag_WeightedEstimate=Nag_IncludeWeight_start
Nag_UnweightedEstimate} Nag_IncludeWeight;
typedef enum {Nag_MeanInclude=Nag_IncludeMean_start, Nag_MeanZero}
Nag_IncludeMean;
typedef enum {Nag_ObservAdd=Nag_UpdateObserv_start, Nag_ObservDel}
Nag_UpdateObserv;
typedef enum {Nag_AboutMean=Nag_SumSquare_start, Nag_AboutZero} Nag_SumSquare;
typedef enum {Nag_FirstCall=Nag_Initialize_start, Nag_Update} Nag_Initialize;
typedef enum {Nag_Expo=Nag_Link_start, Nag_Iden, Nag_Log, Nag_Sqrt, Nag_Reci,
Nag_Logistic, Nag_Probit, Nag_Compl} Nag_Link;
typedef enum {Nag_RegNotSet=Nag_RegType_start, Nag_HuberReg, Nag_MallowsReg,
Nag_SchweppeReg} Nag_RegType;
typedef enum {Nag_PsiNotSet=Nag_PsiFun_start, Nag_Lsq, Nag_HuberFun,
Nag_HampelFun, Nag_AndrewFun, Nag_TukeyFun} Nag_PsiFun;
typedef enum {Nag_SigmaNotSet=Nag_SigmaEst_start, Nag_SigmaRes, Nag_SigmaConst,
Nag_SigmaChi} Nag_SigmaEst;
typedef enum {Nag_CovNotSet=Nag_CovMatrixEst_start, Nag_CovMatAve,
Nag_CovMatObs} Nag_CovMatrixEst;
typedef enum {Nag_SigmaSimul=Nag_SigmaSimulEst_start, Nag_SigmaBypas}
Nag_SigmaSimulEst;
typedef enum {Nag_MatCorrelation=Nag_PrinCompMat_start, Nag_MatStandardised,
Nag_MatSumSq, Nag_MatVarCovar} Nag_PrinCompMat;
typedef enum {Nag_ScoresStand=Nag_PrinCompScores_start, Nag_ScoresNotStand,
Nag_ScoresUnitVar, Nag_ScoresEigenval} Nag_PrinCompScores;
typedef enum {Nag_NoWeights=Nag_Weightstype_start, Nag_Weightsfreq,
Nag_Weightsvar} Nag_Weightstype;
typedef enum {Nag_RoLoadStand=Nag_RotationLoading_start, Nag_RoLoadNotStand}
Nag_RotationLoading;
typedef enum {Nag_NoTransNorm=Nag_TransNorm_start, Nag_Orig, Nag_OrigCentroid,
Nag_Norm, Nag_OrigNorm, Nag_OrigNormCentroid} Nag_TransNorm;
typedef enum {Nag_LsqScale=Nag_RotationScale_start, Nag_NotLsqScale}
Nag_RotationScale;
typedef enum {Nag_DataCorr=Nag_FacMat_start, Nag_DataCovar, Nag_MatCorr_Covar}
Nag_FacMat;
typedef enum {Nag_FacScoreRegsn=Nag_FacScoreMethod_start, Nag_FacScoreBart}
Nag_FacScoreMethod;
typedef enum {Nag_FacRotate=Nag_FacRotation_start, Nag_FacNoRotate}
Nag_FacRotation;
typedef enum {Nag_EqualCovar=Nag_GroupCovars_start, Nag_NotEqualCovar}
Nag_GroupCovars;
typedef enum {Nag_SamplePoints=Nag_MahalDist_start, Nag_GroupMeans}
Nag_MahalDist;
typedef enum {Nag_DiscrimEstimate=Nag_DiscrimMethod_start, Nag_DiscrimPredict}
Nag_DiscrimMethod;
typedef enum {Nag_EqualPrior=Nag_PriorProbability_start, Nag_GroupSizePrior,
Nag_UserPrior} Nag_PriorProbability;
typedef enum {Nag_MatUp=Nag_MatUpdate_start, Nag_NoMatUp} Nag_MatUpdate;
typedef enum {Nag_DistAbs=Nag_DistanceType_start, Nag_DistEuclid,
Nag_DistSquared} Nag_DistanceType;
typedef enum {Nag_VarScaleStd=Nag_VarScaleType_start, Nag_VarScaleRange,
Nag_VarScaleUser, Nag_NoVarScale} Nag_VarScaleType;
typedef enum {Nag_SingleLink=Nag_ClusterMethod_start, Nag_CompleteLink,
Nag_GroupAverage, Nag_Centroid, Nag_Median, Nag_MinVariance}
Nag_ClusterMethod;
typedef enum {Nag_DendNorth=Nag_DendOrient_start, Nag_DendSouth, Nag_DendEast,
Nag_DendWest} Nag_DendOrient;
typedef enum {Nag_AllEigVals=Nag_Eigenvalues_start, Nag_LargeEigVals}
Nag_Eigenvalues;
typedef enum {Nag_Stress=Nag_ScaleCriterion_start, Nag_SStress}
Nag_ScaleCriterion;
typedef enum {Nag_NoBlocks=Nag_Blocks_start, Nag_SerialBlocks,
Nag_ParallelBlocks} Nag_Blocks;
typedef enum {Nag_PDF=Nag_DiscreteDistrib_start, Nag_CDF} Nag_DiscreteDistrib;
typedef enum {Nag_PopVarEqual=Nag_PopVar_start, Nag_PopVarNotEqual} Nag_PopVar;
typedef enum {Nag_4253H=Nag_Smooth_Type_start, Nag_3RSSH} Nag_Smooth_Type;
typedef enum {Nag_Freq=Nag_FreqTime_start, Nag_NoFreq} Nag_FreqTime;
typedef enum {Nag_CriteriaNotSet=Nag_Likelihood_start, Nag_LeastSquares,
Nag_Exact, Nag_Marginal} Nag_Likelihood;
typedef enum {Nag_Rectangular=Nag_LagWindow_start, Nag_Bartlett, Nag_Tukey,
Nag_Parzen} Nag_LagWindow;
typedef enum {Nag_NoCorrection=NagMeanOrTrend_start, Nag_Mean, Nag_Trend}
NagMeanOrTrend;
typedef enum {Nag_Unlogged=Nag_LoggedSpectra_start, Nag_Logged}
Nag_LoggedSpectra;
typedef enum {Nag_next_state=Nag_state_start, Nag_curr_state} Nag_state;
typedef enum {Nag_ab_prod=Nag_ab_input_start, Nag_ab_sep} Nag_ab_input;
typedef enum {Nag_UH_Observer=Nag_ObserverForm_start, Nag_LH_Observer}
Nag_ObserverForm;
typedef enum {Nag_UH_Controller=Nag_ControllerForm_start, Nag_LH_Controller}
Nag_ControllerForm;
H Chapters
typedef enum {Nag_OutputNotSet=Nag_OutputType_start, Nag_NoOutput,
Nag_MPS_Summary, Nag_MPS_List} Nag_OutputType;
typedef enum {Nag_BB_OK=Nag_BB_Fail_start, Nag_BB_Alloc_Fail,
Nag_BB_Internal_Error} Nag_BB_Fail;
typedef enum {Nag_MIP_TypeNotSet=Nag_MIP_ProbType_start, Nag_MILP, Nag_MIQP1,
Nag_MIQP2, Nag_MIQP3, Nag_MIQP4} Nag_MIP_ProbType;
typedef enum {Nag_NodSel_NotSet=Nag_Node_Selection_start, Nag_Deep_Search,
Nag_Broad_Search, Nag_MinObj_Search, Nag_DeepBroad_Search,
Nag_DeepMinObj_Search} Nag_Node_Selection;
typedef enum {Nag_VarSel_NotSet=Nag_Var_Selection_start, Nag_First_Int,
Nag_Nearest_Half, Nag_Use_Priority} Nag_Var_Selection;
typedef enum {Nag_BrDir_NotSet=Nag_Branch_Direction_start, Nag_Branch_Left,
Nag_Branch_Right, Nag_Branch_InitX} Nag_Branch_Direction;
typedef enum {Nag_NS_NotSet=Nag_NodeStatus_start, Nag_NS_NotSolved,
Nag_NS_NotBranched, Nag_NS_Integer, Nag_NS_Bounded,
Nag_NS_Infeasible, Nag_NS_Terminated} Nag_NodeStatus;
M Chapters
typedef enum {Nag_Ascending=Nag_SortOrder_start, Nag_Descending} Nag_SortOrder;
typedef enum {Nag_First=Nag_SearchMatch_start, Nag_Last} Nag_SearchMatch;
X Chapters
typedef enum {Nag_HashOK=Nag_HashError_start, Nag_HashTableTooBig}
Nag_HashError;
Appendix
C. Examples
This section contains Visual Basic code fragments that illustrate how to call various C DLL functions; it also gives the C DLL function prototypes and, where required, template C code to create the auxiliary DLL. Note that the fragments presented here are incomplete and are reproduced for illustrative purposes only. The complete code for these examples (and for a few more) are contained in the Excel workbook run_examples.xls, and has been tested using both Excel and Visual Basic.
extern void __stdcall e02bac(Integer m, double x[], double y[], double weights[], double *ss, Nag_Spline *spline, NagError *fail); extern void __stdcall e02bbc(double x, double *s, Nag_Spline *spline, NagError *fail);Visual Basic declarations
Declare Sub e02bac Lib "nagcd.dll" Alias "_e02bac@28" (ByVal m As Long, _ x As Double, y As Double, weights As Double, ss As Double, _ spline As NagSpline, ifail As NagErrorType) Declare Sub e02bbc Lib "nagcd.dll" Alias "_e02bbc@20" (ByVal x As Double, _ s As Double, spline As NagSpline, fail As NagErrorType)Visual Basic code
Static Aspline As NagSpline Static nl As Long Static lamda(14) As Double Static c(8) As Double Static ptr As Long Dim pfail As NagErrorType Aspline.n = nl ' allocate and assign nl elements to Aspline.lamda Call set_double_pointer(Aspline.lamda, lamda(0), nl) Call e02bac(m, x(0), y(0), weights(0), ss, Aspline, pfail) ' copy nl elements from Aspline.lamda to the Visual Basic array lamda, and ' 8 elements from the (internally allocated) pointer Aspline.c Call get_double_pointer(Aspline.lamda, lamda(0), nl) Call get_double_pointer(Aspline.c, c(0), 8) For i = 0 To 7 Print #1, Format(c(i), " ##0.0000;-##0.0000") Next i For i = 0 To m - 1 Step 1 xarg = x(i) Call e02bbc(xarg, fit, Aspline, pfail) Print #1, i, Format(x(i), " ##0.0000;-##0.0000"), _ Format(fit, "##0.0000;-##0.0000") If (i < m - 1) Then j = j + 1 xarg = (x(i) + x(i + 1)) * 0.5 Call e02bbc(xarg, fit, Aspline, pfail) Print #1, Format(xarg, " ##0.0000;-##0.0000"), _ Format(fit, "##0.0000;- ##0.0000") End If j = j + 1 Next i ' free allocated memory Call free(Aspline.lamda) Call free(Aspline.c)SVD example
extern void __stdcall f02wec(Integer m, Integer n, double *a, Integer tda, Integer ncolb, double *b, Integer tdb, Boolean wantq, double *q, Integer tdq, double *sv, Boolean wantp, double *pt, Integer tdpt, Integer *iter, double *e, Integer *failinfo, NagError *fail);Visual Basic declarations
Declare Sub f02wec Lib "nagcd.dll" Alias "_f02wec@72" (ByVal m As Long, _ ByVal n As Long, a As Double, ByVal tda As Long, ByVal ncolb As Long, _ b As Double, ByVal tdb As Long, ByVal wantq As Long, q As Double, _ ByVal tdq As Long, sv As Double, ByVal wantp As Long, pt As Double, _ ByVal tdpt As Long, iter As Long, e As Double, failinfo As Long, _ Ifail As NagErrorType)Allow the use of null pointers
Declare Sub f02wec_ptr Lib "nagcd.dll" Alias "_f02wec@72" (ByVal m As Long, _ ByVal n As Long, a As Double, ByVal tda As Long, ByVal ncolb As Long, _ ByVal b As Long, ByVal tdb As Long, ByVal wantq As Long, ByVal q As Long, _ ByVal tdq As Long, sv As Double, ByVal wantp As Long, ByVal pt As Long, _ ByVal tdpt As Long, iter As Long, e As Double, failinfo As Long, _ Ifail As NagErrorType)Visual Basic code
Static a(m*n-1) As Double Static a2(m*n-1) As Double Static q(m*n-1) As Double Static sv(m-1) As Double Static pt(0) As Double Static e(m-1) As Double Static dum(0) As Double Dim pfail As NagErrorType pfail.code = 0 pfail.printm = 1 ncolb = 0 tda = n For i = 0 To m - 1 For j = 0 To n - 1 Input #2, a(i * tda + j) a2(i * tda + j) = a(i * tda + j) Next j Next i tdb = 0 tdpt = 0 tdq = n wtp = 1 wtq = 1 ' calculate the singular values and also the left and right singular vectors Call f02wec(m, n, a2(0), tda, ncolb, dum(0), tdb, wtq, q(0), tdq, sv(0), _ wtp, pt(0), tdpt, iter, e(0), info, pfail) tdq = 0 wtq = 0 wtp = 0 ' only calculate the singular values, call f02wec_ptr with 3 null pointers Call f02wec_ptr(m, n, a(0), tda, ncolb, ByVal 0&, tdb, wtq, ByVal 0&, tdq, _ sv(0), wtp, ByVal 0&, tdpt, iter, e(0), info, pfail)ODE example
typedef void (__stdcall * NAG_D02EJC_FUN)(Integer neq, double x, double y[], double *f, Nag_User *comm); typedef void (__stdcall * NAG_D02EJC_PFUN)(Integer neq, double x, double y[], double pw[], Nag_User *comm); typedef void (__stdcall * NAG_D02EJC_OUTFUN)(Integer neq, double *xsol, double y[], Nag_User *comm); typedef double (__stdcall * NAG_D02EJC_GFUN)(Integer neq, double x, double y[], Nag_User *comm); extern void __stdcall d02ejc(Integer neq, NAG_D02EJC_FUN fcn, NAG_D02EJC_PFUN pederv, double *t, double y[], double tend, double tol, Nag_ErrorControl err_c, NAG_D02EJC_OUTFUN output, NAG_D02EJC_GFUN g, Nag_User *comm, NagError *fail);Auxiliary DLL template code
#define DllExport __declspec( dllexport )
void local_d02ejc_fcn(Integer neq, double x, double y[], double f[], Nag_User
*comm);
void local_d02ejc_pederv(Integer neq, double x, double y[], double pw[],
Nag_User *comm);
DllExport long d02ejc_pederv(void) { return (long)(local_d02ejc_pederv);}
DllExport long d02ejc_fcn(void) { return (long)(local_d02ejc_fcn);}
void local_d02ejc_fcn(Integer neq, double x, double y[], double f[], Nag_User
*comm) {
< ... Insert C code ... >
}
void local_d02ejc_pederv(Integer neq, double x, double y[], double pw[],
Nag_User *comm) {
< ... Insert C code ... >
}
Visual Basic declarations
Declare Sub d02ejc Lib "nagcd.dll" Alias "_d02ejc@56" (ByVal neq As Long, _ ByVal ptr_fcn As Long, ByVal ptr_pederv As Long, x As Double, y As Double, _ ByVal xend As Double, ByVal tol As Double, ByVal err_c As Long, _ ByVal ptr_output As Long, ByVal ptr_g As Long, comm As Nag_User, _ ifail As NagErrorType) Declare Function d02ejc_fcn Lib "examples_interfaces.dll" Alias _ "_d02ejc_fcn@0" () As Long Declare Function d02ejc_pederv Lib "examples_interfaces.dll" Alias _ "_d02ejc_pederv@0" () As LongVisual Basic code
Static err_c As Long Static comm As Nag_User Static y(2) As Double Static fcn_ptr As Long Static pederv_ptr As Long Dim pfail As NagErrorType ' user-defined Jacobian; use pointers d02ejc_fcn, d02ejc_pederv xend = x + 2# fcn_ptr = d02ejc_fcn pederv_ptr = d02ejc_pederv Call d02ejc(neq, fcn_ptr, pederv_ptr, x, y(0), xend, tol, err_c, 0, 0, comm, _ pfail) Print #1, x, y(0), y(1), y(2) ' internal evaluation of Jacobian; use pointer d02ejc_fcn xend = x + 2# fcn_ptr = d02ejc_fcn Call d02ejc(neq, fcn_ptr, ByVal 0&, x, y(0), xend, tol, err_c, _ ByVal 0&, ByVal 0&, comm, pfail) Print #1, x, y(0), y(1), y(2)Optimize example
typedef void (__stdcall * NAG_E04UCC_FUN)(Integer, double *, double *, double *, Nag_Comm *); typedef void (__stdcall * NAG_E04UCC_CONFUN)(Integer, Integer, Integer *, double *, double *, double *, Nag_Comm *); extern void __stdcall e04ucc(Integer n, Integer nclin, Integer ncnlin, double a[], Integer tda, double bl[], double bu[], NAG_E04UCC_FUN objfun, NAG_E04UCC_CONFUN confun, double x[], double *objf, double objgrad[], Nag_E04_Opt *options, Nag_Comm *user_comm, NagError *fail);Auxiliary DLL template code
#define DllExport __declspec( dllexport )
void local_e04ucc_objfun(Integer n, double x[], double *objf,double objgrd[],
Nag_Comm *comm);
void local_e04ucc_confun(Integer n, Integer ncnlin, Integer needc[], double x[],
double conf[], double conjac[], Nag_Comm *comm);
DllExport long e04ucc_objfun(void) { return (long)(local_e04ucc_objfun);}
DllExport long e04ucc_confun(void) { return (long)(local_e04ucc_confun);}
void local_e04_objfun(long n, double *x, double *objf, double *g, Nag_Comm
*comm) {
< ... Insert C code ... >
}
void local_e04ucc_objfun(Integer n, double x[], double *objf, double objgrd[],
Nag_Comm *comm) {
< ... Insert C code ... >
}
void local_e04ucc_confun(Integer n, Integer ncnlin, Integer needc[], double
x[],double conf[], double conjac[], Nag_Comm *comm) {
< ... Insert C code ... >
}
Visual Basic declarations
Declare Sub e04ucc Lib "nagcd.dll" Alias "_e04ucc@60" (ByVal n As Long, _ ByVal nclin As Integer, ByVal ncnlin As Integer, a As Double, _ ByVal tda As Integer, bl As Double, bu As Double, _ ByVal objfun_ptr As Long, ByVal confun_ptr As Long, x As Double, _ objf As Double, g As Double, ByVal options_ptr As Long, comm As Any, _ fail As NagErrorType) Declare Function e04_objfun Lib "examples_interfaces.dll" Alias _ "_e04_objfun@0" () As Long Declare Function e04ucc_confun Lib "examples_interfaces.dll" Alias _ "_e04ucc_confun@0" () As LongVisual Basic code
Static a(nclin * n) Static bu(totalvars) Static x(n) Static bl(totalvars) Static objgrd(n) Static objf As Double Static objfun_ptr As Long Static confun_ptr As Long Dim pfail As NagErrorType tda = n pfail.code = 0 ' call the optimizer using function pointers e04ucc_objfun and e04ucc_confun objfun_ptr = e04ucc_objfun confun_ptr = e04ucc_confun Call e04ucc(n, nclin, ncnlin, a(0), tda, bl(0), bu(0), objfun_ptr, _ confun_ptr, x(0), objf, objgrd(0), 0, ByVal 0&, pfail)Integrate example
typedef double (__stdcall * NAG_D01AJC_FUN)(double); extern void __stdcall d01ajc(NAG_D01AJC_FUN f, double a, double b, double epsabs, double epsrel, Integer max_num_subint, double *result, double *abserr, Nag_QuadProgress *qp, NagError *fail);Auxiliary DLL template code
#define DllExport __declspec( dllexport )
double local_d01ajc_fun1(double x);
double local_d01ajc_fun2(double x);
DllExport long d01ajc_fun1(void) { return (long)(local_d01ajc_fun1);}
DllExport long d01ajc_fun2(void) { return (long)(local_d01ajc_fun2);}
double local_d01ajc_fun1(double x) {
< ... Insert C code ... >
return ( < ... Insert C code ... > );
}
double local_d01ajc_fun2(double x) {
< ... Insert C code ... >
return ( < ... Insert C code ... > );
}
Visual Basic declarations
Declare Sub d01ajc Lib "nagcd.dll" Alias "_d01ajc@56" (ByVal ptr As Long, _ ByVal a As Double, ByVal b As Double, ByVal epsabs As Double, _ ByVal epsres As Double, ByVal max_num_sunint As Long, result As Double, _ abserr As Double, qp As NagQuadProgress, fail As NagErrorType) Declare Function d01ajc_fun1 Lib "examples_interfaces.dll" Alias _ "_d01ajc_fun1@0" () As Long Declare Function d01ajc_fun2 Lib "examples_interfaces.dll" Alias _ "_d01ajc_fun2@0" () As LongVisual Basic code
Static qp As NagQuadProgress Static a As Double Static b As Double Static epsabs As Double Static epsrel As Double Static result As Double Static max_num_subint As Long Static abserr As Double Static pi As Double Static fun_ptr As Long Dim pfail As NagErrorType pi = 4# * Atn(1#) a = 0# b = 2 * pi max_num_subint = 200 epsabs = 0# epsrel = 0.0001 pfail.printm = 1 pfail.code = 0 ' integrate function 1; use pointer d01ajc_fun1 fun_ptr = d02ajc_fun1 Call d01ajc(fun_ptr, a, b, epsabs, epsrel, max_num_subint, result, abserr, _ qp, pfail) ' integrate function 2; use pointer d01ajc_fun2 fun_ptr = d02ajc_fun2 Call d01ajc(fun_ptr, a, b, epsabs, epsrel, max_num_subint, result, abserr, _ qp, pfail)